package com.app.studyroom.api;

import com.app.studyroom.api.model.message.LearningRankingItem;
import com.app.studyroom.api.model.message.MessageIndexResponse;
import com.app.studyroom.api.model.message.MessagePageRequest;
import com.app.studyroom.api.model.message.MessagePageResponse;
import com.app.studyroom.api.model.message.SeatRateItem;
import com.app.studyroom.api.model.messageNotice.DeleteMessageRequest;
import com.app.studyroom.api.model.messageNotice.MessageItem;
import com.app.studyroom.api.model.messageNotice.MessageStatusUpdateRequest;
import com.app.studyroom.api.model.ssrApproval.ApprovalCompleteRequest;
import com.app.studyroom.api.model.ssrBooking.BookingDeleteRequest;
import com.app.studyroom.api.model.ssrBooking.BookingPageRequest;
import com.app.studyroom.api.model.ssrBooking.BookingPageResponse;
import com.app.studyroom.api.model.ssrBooking.BookingSaveRequest;
import com.app.studyroom.api.model.ssrBooking.BookingUpdateRequest;
import com.app.studyroom.api.model.ssrBooking.SelfStudyRequest;
import com.app.studyroom.api.model.ssrGet.ApprovalTaskResponse;
import com.app.studyroom.api.model.ssrGet.ClassroomResponse;
import com.app.studyroom.api.model.ssrGet.OpenStatusRequest;
import com.app.studyroom.api.model.ssrGet.OpenStatusResponse;
import com.app.studyroom.api.model.ssrSeat.DeleteSeatBookingRequest;
import com.app.studyroom.api.model.ssrSeat.PageSeatListRequest;
import com.app.studyroom.api.model.ssrSeat.PageSeatListResponse;
import com.app.studyroom.api.model.ssrSeat.SeatDeatilBean;
import com.app.studyroom.api.model.ssrSeat.SeatDeatilRequest;
import com.app.studyroom.api.model.ssrSeat.SeatDeleteRequest;
import com.app.studyroom.api.model.ssrSeat.SeatItem;
import com.app.studyroom.api.model.ssrSeat.SeatSaveRequest;
import com.app.studyroom.api.model.ssrSeat.SeatUpdateRequest;
import com.app.studyroom.api.model.ssrUser.BindUserRequest;
import com.app.studyroom.api.model.ssrUser.IsUserBindResponse;
import com.app.studyroom.api.model.ssrUser.LoginRequest;
import com.app.studyroom.api.model.ssrUser.PageUserListResponse;
import com.app.studyroom.api.model.ssrUser.QyAdminListRequest;
import com.app.studyroom.api.model.ssrUser.RegisterRequest;
import com.app.studyroom.api.model.ssrUser.PageUserListRequest;
import com.app.studyroom.api.model.ssrUser.StudyDurationItem;
import com.app.studyroom.api.model.ssrUser.UserDeleteRequest;
import com.app.studyroom.api.model.ssrUser.UserIdRequest;
import com.app.studyroom.api.model.ssrUser.UserItem;
import com.app.studyroom.api.model.ssrUser.UserSaveRequest;
import com.app.studyroom.api.model.ssrUser.UserStudyDuration;
import com.app.studyroom.api.model.ssrUser.UserUpdateRequest;
import com.app.studyroom.db.AreaInfo;
import com.app.studyroom.db.UserInfo;

import java.util.List;
import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;

public interface ApiService {


    //用户管理
    // 登录接口
    @POST("ssrUser/login")
    Call<ApiResponse<UserInfo>> login(
            @Body LoginRequest loginRequest
    );

    //注册接口
    @POST("ssrUser/register")
    Call<ApiResponse<Object>> register(
            @Body RegisterRequest registerRequest
    );

    //用户分页查询
    @POST("ssrUser/pageUserList")
    Call<PageUserListResponse> pageUserList(
            @Header("Authorization") String token,
            @Body PageUserListRequest request
    );
    //更新用户
    @POST("ssrUser/userUpdate")
    Call<ApiResponse<Object>> userUpdate(
            @Header("Authorization") String token,
            @Body UserUpdateRequest updateRequest
    );

    //删除用户
    @POST("ssrUser/userDelete")
    Call<ApiResponse<Object>> userDelete(
            @Header("Authorization") String token,
            @Body UserDeleteRequest deleteRequest
    );

    @POST("ssrUser/userSave")
    Call<ApiResponse<Object>> userSave(
            @Header("Authorization") String token,
            @Body UserSaveRequest saveRequest
    );

    @POST("ssrUser/getById")
    Call<ApiResponse<UserInfo>> getUserById(
            @Body UserIdRequest request
    );

    @POST("ssrUser/bindUser")
    Call<Map<String, String>> getRawBindableUsers(
            @Header("Authorization") String token,
            @Body BindUserRequest request
    );
    @POST("ssrUser/getQyAdmin")
    Call<ApiResponse<List<UserItem>>> getQyAdminList(
            @Header("Authorization") String token,
            @Body QyAdminListRequest request
    );
    //不用token获取全部管理员
    @POST("ssrUser/userAdmin")
    Call<ApiResponse<List<UserInfo>>> getAllUserAdmin();

    @POST("ssrUser/isUserBind")
    Call<ApiResponse<IsUserBindResponse>> isUserBind(
            @Header("Authorization") String token
    );

    @POST("ssrUser/userList")
    Call<ApiResponse<List<UserInfo>>> getUserList(
            @Header("Authorization") String token
    );

    @POST("ssrUser/userCumulative-duration")
    Call<ApiResponse<List<StudyDurationItem>>> getUserStudyDurations(
            @Header("Authorization") String token
    );


    //座位管理
    @POST("ssrSeat/seatPage")
    Call<PageSeatListResponse> pageSeatList(
            @Header("Authorization") String token,
            @Body PageSeatListRequest request
    );
    //无toekn，无筛选
    //因为传的参数一样所以seatPage和seatList共用了请求和接收
    @POST("ssrSeat/seatList")
    Call<PageSeatListResponse> seatList(
            @Body PageSeatListRequest request
    );

    @POST("ssrSeat/seatSave")
    Call<ApiResponse<Object>> seatSave(
            @Header("Authorization") String token,
            @Body SeatSaveRequest request
    );

    @POST("ssrSeat/seatUpdate")
    Call<ApiResponse<Object>> seatUpdate(
            @Header("Authorization") String token,
            @Body SeatUpdateRequest request
    );

    @POST("ssrSeat/seatDelete")
    Call<ApiResponse<Object>> seatDelete(
            @Header("Authorization") String token,
            @Body SeatDeleteRequest request
    );
    @POST("ssrSeat/seatDeatil")
    Call<ApiResponse<SeatDeatilBean>> seatDeatil(
            @Header("Authorization") String token,
            @Body SeatDeatilRequest request
    );

    @POST("ssrSeatBooking/unblockBooking")
    Call<ApiResponse<Object>> deleteSeatBooking(
            @Header("Authorization") String token,
            @Body DeleteSeatBookingRequest request
    );


//     获取详情（可选）
//    @POST("seatDeatil")
//    Call<ApiResponse<SeatItem>> seatDetail(@Body SeatDetailRequest request);

    // 预约分页查询
    @POST("ssrBooking/ssrBookingPage")
    Call<BookingPageResponse> pageBookingList(
            @Header("Authorization") String token,
            @Body BookingPageRequest request
    );

    // 新增预约
    @POST("ssrBooking/ssrBookingSave")
    Call<ApiResponse<Object>> saveBooking(
            @Header("Authorization") String token,
            @Header("Enable") String enable,
            @Body BookingSaveRequest request
    );

    //  更新预约
    @POST("ssrBooking/ssrBookingUpdate")
    Call<ApiResponse<Object>> updateBooking(
            @Header("Authorization") String token,
            @Body BookingUpdateRequest request
    );

    //  删除预约
    @POST("ssrBooking/ssrBookingDelete")
    Call<ApiResponse<Object>> deleteBooking(
            @Header("Authorization") String token,
            @Body BookingDeleteRequest request
    );
    @POST("ssrBooking/ssrSeatBookingStart")
    Call<ApiResponse<Object>> startOrEndSelfStudy(
            @Header("Authorization") String token,
            @Body SelfStudyRequest request
    );

    //get接口
    //区域树
    @POST("region/allXjTreeQy")
    Call<ApiResponse<List<AreaInfo>>> getAreaList();
    @GET("region/treeQy")
    Call<ApiResponse<List<ClassroomResponse>>> getClassroomTree();  // 不需要token
    @GET("universalUtil/getSeatEnum")
    Call<ApiResponse<Map<String, String>>> getSeatStatusEnum();
    @GET("universalUtil/getMessagesEnum")
    Call<ApiResponse<Map<String, String>>> getMessagesEnum();
    @GET("universalUtil/getApprovalEnum")
    Call<ApiResponse<Map<String, String>>> getApprovalStatusEnum();
    @POST("ssrUser/getAllAdmin")
    Call<ApiResponse<List<UserInfo>>> getAllQyAdmins(
            @Header("Authorization") String token
    );
    @POST("report/generate-report")
    Call<ApiResponse<Object>> generateStudyReport(
            @Header("Authorization") String token
    );
    @POST("report/generate-report")
    Call<ResponseBody> generateStudyReportRaw(
            @Header("Authorization") String token
    );


    //消息接口
    @POST("message/seatRate")
    Call<ApiResponse<List<SeatRateItem>>> getSeatRateList();
    @POST("message/index")
    Call<ApiResponse<MessageIndexResponse>> getMessageIndex();
    @POST("message/save")
    Call<ApiResponse<Object>> publishAnnouncement(
            @Body Map<String, String> requestBody
    );
    @POST("message/page")
    Call<ApiResponse<MessagePageResponse>> getMessagePage(
            @Header("Authorization") String token,
            @Body MessagePageRequest request
    );
    @POST("message/delete")
    Call<ApiResponse<Object>> deleteMessage(
            @Header("Authorization") String token,
            @Body Map<String, String> body
    );
    @POST("message/studyRanking")
    Call<ApiResponse<List<LearningRankingItem>>> getLearningRanking(); // 不带参数

    //审批
    @POST("approval/tasks")
    Call<List<ApprovalTaskResponse>> getApprovalTaskList(
            @Header("Authorization") String token
    );
    @GET("ssrOpen/list")
    Call<ApiResponse<OpenStatusResponse>> getOpenStatus();
    @POST("ssrOpen/save")
    Call<ApiResponse<OpenStatusResponse>> saveOpenStatus(
            @Body OpenStatusRequest request
    );
    @POST("approval/complete")
    Call<ApiResponse<Object>> completeApproval(
            @Header("Authorization") String token,
            @Body ApprovalCompleteRequest request
    );


    // 图片上传接口
    @Multipart
    @POST("ssrImage/upload")
    Call<ApiResponse<Map<String, String>>> uploadImage(
            @Part MultipartBody.Part file
    );
    //id解析接口
    @POST("ssrImage/detail")
    Call<ApiResponse<String>> getImageDetail(
            @Body Map<String, String> id
    );


    //消息通知接口
    @POST("api/messages/list")
    Call<ApiResponse<List<MessageItem>>> getMessageList(
            @Header("Authorization") String token
    );
    @POST("api/messages/delete")
    Call<ApiResponse<Object>> deleteMessage(
            @Header("Authorization") String token,
            @Body DeleteMessageRequest request
    );
    @POST("api/messages/read")
    Call<ApiResponse<Object>> updateMessageStatus(
            @Header("Authorization") String token,
            @Body MessageStatusUpdateRequest request
    );


}
